package com.qinge.blog.security;

import com.alibaba.fastjson.JSON;

import com.qinge.blog.utils.redis.RedisUtil;
import com.qinge.blog.utils.result.JsonResult;
import com.qinge.blog.utils.result.ResultCode;
import com.qinge.blog.utils.result.ResultTool;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author QDW
 * @date 2022/4/29 12:16
 * @description CustomizeLogoutSuccessHandler
 **/
@Component
public class LogoutSuccessHandlerImpl implements LogoutSuccessHandler {
    @Resource
    private RedisUtil redisUtil;

    @Override
    public void onLogoutSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, IOException {
        JsonResult result = ResultTool.success();
        httpServletResponse.setContentType("text/json;charset=utf-8");
        httpServletResponse.getWriter().write(JSON.toJSONString(result));
    }

}
